package com.copa.l1309;

import java.util.LinkedList;

/**
 * @author copa
 * @createDate 2022-09-02 12:46
 * @function 一次遍历法
 */
public class Test1 {

    /**
     * 1-9 判断 +48
     * a-i 97-105
     * 1-9 49-57
     * 10#-26# 直接用数字 +96
     * j-z 106-122
     * 10# -> j
     *
     * @param s
     * @return
     */
    public String freqAlphabets(String s) {
        LinkedList<String> linkedList = new LinkedList<>();
        int temp = s.length() - 1;
        while (temp >= 0) {
            if (s.charAt(temp) == '#') {
                char a = (char) (Integer.parseInt(s.substring(temp - 2, temp))  + 96);
                linkedList.addFirst(String.valueOf(a));
                temp -= 3;
                continue;
            }
            char a = (char) (s.charAt(temp) + 48);
            linkedList.addFirst(String.valueOf(a));
            temp--;
        }
        return String.join("", linkedList);
    }

    public static void main(String[] args) {
        String s = "10#11#12";
        System.out.println(new Test1().freqAlphabets(s));
    }
}
